<?php

namespace Bean\Flow\GenericFlow;

abstract class Comment extends \Library\Bean {

	public abstract function getUser();
	
	public abstract function getMessage();
	
	public abstract function getPublicationTime();
	
	public abstract function getPost();
	
	public abstract function getCommentId();
	
	public function isLikable( \Bean\User $user = null ) {
		return false;
	}
	
	public function isDeletable( \Bean\User $user = null ) {
		return false;
	}
	
	public function getLikes() {
		throw new \Exception( 'Not implemented' );
	}
	
	public function isLikedBy( \Bean\User $user = null ) {
		throw new \Exception( 'Not implemented' );
	}
		
	public function like( \Bean\User $user = null ) {
		throw new \Exception( 'Not implemented' );
	}
	
	public function unlike( \Bean\User $user = null ) {
		throw new \Exception( 'Not implemented' );
	}
	
	public function delete() {
		throw new \Exception( 'Not implemented' );
	}
	
	public function getGenericId() {
		preg_match( '/Bean\\\Flow\\\([^\\\]+)Flow/', get_class($this), $match );
		return $match[1] . ':' . $this->getCommentId(); 
	}
	
	public static function get( $genericId, Item $item = null ) {
		$pos = strpos($genericId, ':');
		$class = '\Bean\Flow\\' . substr($genericId, 0, $pos) . 'Flow\Comment';
		return $class::get( substr($genericId, $pos+1), $item );
	}
	
	public function getView() {
		return 'Widget/Flow/GenericFlow/Comment';
	}
}
